//
//  LCGlobalService.m
//  lechuang
//
//  Created by Mr_hi on 2024/8/27.
//  Copyright © 2024 Mooyi. All rights reserved.
//

#import "LCGlobalService.h"

@implementation LCGlobalService

//获取全域推链接
+(void)getGlobalLinkWithBlock:(void(^)(BOOL isSuccess, NSArray <LCCouponLinkModel *>* list))block {
    NSMutableDictionary *param = [NSMutableDictionary new];
    param[@"Groupname"] = @"全域推";
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLLinks) HttpMethod:KGet HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            NSArray *list = [LCCouponLinkModel mj_objectArrayWithKeyValuesArray:result[@"result"]];
            block(YES, list);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO, nil);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO, nil);
    }];
}

//获取短剧列表
+(void)getVideoListWithPage:(NSInteger)page Block:(void(^)(BOOL isSuccess, NSArray <LCGlobalVideoModel *>* list, NSInteger total))block {
    NSMutableDictionary *param = [NSMutableDictionary new];
    param[@"page"] = kFORMAT(@"%ld", page);
    param[@"pagesize"] = @"15";
    
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLVideoList) HttpMethod:KGet HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            NSArray *list = [LCGlobalVideoModel mj_objectArrayWithKeyValuesArray:result[@"result"]];
            NSInteger total = [result[@"record"] integerValue];
            block(YES, list, total);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO, nil, 0);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO, nil, 0);
    }];
}

//获取短剧详情
+(void)getVideoDetailWithParam:(NSMutableDictionary *)param Block:(void(^)(BOOL isSuccess, LCGlobalVideoModel * model))block {
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLVideoDetail) HttpMethod:KGet HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            LCGlobalVideoModel * model = [LCGlobalVideoModel mj_objectWithKeyValues:result[@"field"]];
            block(YES, model);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO, nil);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO, nil);
    }];
}

//获取短剧列表
+(void)getLifeListWithPage:(NSInteger)page Block:(void(^)(BOOL isSuccess, NSArray <LCGlobalLifeModel *>* list, NSInteger total))block {
    NSMutableDictionary *param = [NSMutableDictionary new];
    param[@"page"] = kFORMAT(@"%ld", page);
    
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLLifeList) HttpMethod:KGet HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            NSArray *list = [LCGlobalLifeModel mj_objectArrayWithKeyValuesArray:result[@"result"]];
            NSInteger total = [result[@"record"] integerValue];
            block(YES, list, total);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO, nil, 0);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO, nil, 0);
    }];
}



//获取旅游列表数据 - GET -- URLTravelList
+(void)getTravelListWithPage:(NSInteger)page Block:(void(^)(BOOL isSuccess, NSArray <LCTravelModel *>* list, NSInteger total))block; {
    NSMutableDictionary *param = [NSMutableDictionary new];
    param[@"page"] = kFORMAT(@"%ld", page);
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLTravelList) HttpMethod:KGet HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            NSArray *list = [LCTravelModel mj_objectArrayWithKeyValuesArray:result[@"result"]];
            NSInteger total = [result[@"record"] integerValue];
            block(YES, list, total);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO, nil, 0);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO, nil, 0);
    }];
}

//旅游报名 - POST -- URLTravelEnroll
+(void)travelEnrollWithTripID:(NSString *)tripid Param:(NSMutableDictionary *)param Block:(void(^)(BOOL isSuccess))block {
    param[@"TripID"] = tripid;
    [[XWXNetWorkQuery sharedManage] AFRequestData:Url(URLTravelEnroll) HttpMethod:KPost HaveToken:YES params:param completionHandle:^(id  _Nonnull result) {
        if ([[result objectForKey:@"success"] boolValue]) {
            block(YES);
        } else {
            [self showErrorText:[result objectForKey:@"tips"]];
            block(NO);
        }
    } errorHandle:^(NSError * _Nonnull error) {
        XWXNetError
        block(NO);
    }];
}


@end
